home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / util / FaxClient.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  4KB  |  114 lines

  1. /*    $Header: /usr/people/sam/fax/util/RCS/FaxClient.h,v 1.17 1994/03/09 18:46:28 sam Rel $ */
  2. /*
  3.  * Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler
  4.  * Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc.
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and 
  7.  * its documentation for any purpose is hereby granted without fee, provided
  8.  * that (i) the above copyright notices and this permission notice appear in
  9.  * all copies of the software and related documentation, and (ii) the names of
  10.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  11.  * publicity relating to the software without the specific, prior written
  12.  * permission of Sam Leffler and Silicon Graphics.
  13.  * 
  14.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  15.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  16.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  17.  * 
  18.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  19.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  20.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  22.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  23.  * OF THIS SOFTWARE.
  24.  */
  25. #ifndef _FaxClient_
  26. #define    _FaxClient_
  27.  
  28. #include "Types.h"
  29. #include "Str.h"
  30. #include <Dispatch/iohandler.h>
  31.  
  32. typedef unsigned int FaxClientRC;
  33.  
  34. class FaxClient : public IOHandler {
  35. private:
  36.     fxStr    host;        // server's host
  37.     fxStr    modem;        // server's modem
  38.     fxBool    verbose;    // print data as sent or received
  39.     fxBool    running;    // client is still running
  40.     fxBool    peerdied;    // server went away
  41.     fxStr    userName;    // sender's account name
  42.     fxStr    senderName;    // sender's full name (if available)
  43.     int        fd;        // input socket
  44.     int        fdOut;        // normally same as fd
  45.     char    buf[1024];    // input buffer
  46.     int        prevcc;        // previous unprocessed input
  47.     u_int    version;    // protocol version
  48.  
  49.     void init();
  50. protected:
  51.     FaxClient();
  52.     FaxClient(const fxStr& hostarg);
  53.     FaxClient(const char* hostarg);
  54.     ~FaxClient();
  55.  
  56.     virtual fxBool setupUserIdentity();
  57.     virtual void setProtocolVersion(u_int);
  58.     virtual void setupHostModem(const char*);
  59.     virtual void setupHostModem(const fxStr&);
  60.  
  61.     virtual void startRunning();
  62.     virtual void stopRunning();
  63.  
  64.     virtual void recvConf(const char* cmd, const char* tag) = 0;
  65.     virtual void recvEof() = 0;
  66.     virtual void recvError(const int err) = 0;
  67.  
  68.     virtual void printError(const char* fmt, ...) = 0;
  69.     virtual void printWarning(const char* va_alist ...) = 0;
  70. public:
  71.     fxBool isRunning() const;
  72.     fxBool getPeerDied() const;
  73.  
  74.     // bookkeeping
  75.     void setHost(const fxStr&);
  76.     void setHost(const char*);
  77.     const fxStr& getHost() const;
  78.     virtual void setModem(const fxStr&);
  79.     virtual void setModem(const char*);
  80.     const fxStr& getModem() const;
  81.     virtual fxBool callServer();
  82.     virtual fxBool hangupServer();
  83.     virtual void setFds(const int in, const int out);
  84.  
  85.     void setVerbose(fxBool);
  86.     fxBool getVerbose() const;
  87.  
  88.     u_int getProtocolVersion() const;
  89.  
  90.     const fxStr& getSenderName() const;
  91.     const fxStr& getUserName() const;
  92.  
  93.     // output
  94.     virtual fxBool sendData(const char* type, const char* filename);
  95.     virtual fxBool sendLine(const char* cmd);
  96.     virtual fxBool sendLine(const char* cmd, int v);
  97.     virtual fxBool sendLine(const char* cmd, const fxStr& s);
  98.     virtual fxBool sendLine(const char* cmd, const char* tag);
  99.  
  100.     // input
  101.     virtual int inputReady(int);
  102. };
  103. inline fxBool FaxClient::isRunning() const        { return running; }
  104. inline fxBool FaxClient::getPeerDied() const        { return peerdied; }
  105. inline const fxStr& FaxClient::getSenderName() const    { return senderName; }
  106. inline const fxStr& FaxClient::getUserName() const    { return userName; }
  107. inline u_int FaxClient::getProtocolVersion() const    { return version; }
  108. inline const fxStr& FaxClient::getHost() const        { return host; }
  109. inline const fxStr& FaxClient::getModem() const        { return modem; }
  110. inline fxBool FaxClient::getVerbose() const        { return verbose; }
  111.  
  112. extern void fxFatal(const char* fmt, ...);
  113. #endif /* _FaxClient_ */
  114.